package com.template.app.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.template.app.dao.TemplateDao;
import com.template.app.exception.ObjectNotFoundException;
import com.template.app.model.Template;
import com.template.app.service.TemplateService;

@Service
public class TemplateServiceImpl implements TemplateService {
	
	@Autowired
	private TemplateDao dao;

	public void save(Template t) {
		dao.save(t);		
	}

	public Template get(Integer id) {
		return dao.get(id);
	}

	public Template getFetch(Integer id) {
		return dao.getFetch(id);
	}

	public void delete(Integer id) {
		Template t = get(id);
		
		if (t == null) {
			throw new ObjectNotFoundException(Template.class, id);
		}
		
		dao.delete(t);			
	}
	
	public List<Template> list() {
		return dao.list();
	}

	public List<Template> lisByTemplateRef(Integer id) {
		return dao.lisByTemplateRef(id);
	}

}
